//
//  CarTeamTwoCell.m
//  阿帕
//
//  Created 阿帕 on 2019/12/28.
//  Copyright © 2019 GCY. All rights reserved.
//

#import "CarTeamTwoCell.h"

@interface CarTeamTwoCell ()
@property (weak, nonatomic) IBOutlet UIImageView *avatarImageView;
@property (weak, nonatomic) IBOutlet UILabel *carTeamNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *carTeamDesLabel;
@property (weak, nonatomic) IBOutlet UIButton *agreeButton;
@property (weak, nonatomic) IBOutlet UIButton *refusedButton;
@property (weak, nonatomic) IBOutlet UIView *lineView;
@property (strong, nonatomic) UILabel *statusTextLabel;

@end

@implementation CarTeamTwoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    cut(_avatarImageView, 40);
    _carTeamNameLabel.textColor = Dark_TextColor;
    _carTeamDesLabel.textColor = Light_TextColor;
    _lineView.backgroundColor = BackgroundColor;
    [_telButton setTitleColor:Dark_TextColor forState:UIControlStateNormal];
    [_telButton setImage:image(@"gcy_icon_carteam_tel") forState:UIControlStateNormal];
    [_telButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:5];
    [_agreeButton setBackgroundColor:Theme_ColorValue];
    [_refusedButton setBackgroundColor:Orange_Color];
    
    //
    _statusTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, _avatarImageView.cy_bottom + 10, ScreenW, 30)];
    _statusTextLabel.textColor = Dark_TextColor;
    _statusTextLabel.text = @"已同意";
    _statusTextLabel.font = font(16);
    _statusTextLabel.hidden = YES;
    _statusTextLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_statusTextLabel];
}
- (IBAction)btnTypeClick:(UIButton *)sender {
    if (self.delegate && [self.delegate respondsToSelector:@selector(cellButtonIndexClick:withButton:)]) {
        [self.delegate cellButtonIndexClick:sender.tag withButton:sender];
    }
}

- (void)setModel:(CarTeamInvitedRecordModel *)model {
    
    _model = model;
    
    _carTeamNameLabel.text = model.name;
    
    _carTeamDesLabel.text = model.linkMan;
    
    setNetImage(_avatarImageView, model.headImg, @"gcy_img_main_head");
    
    [_telButton setTitle:model.phone forState:UIControlStateNormal];
    
    //    status
    //    状态：0未处理，1已同意，2已拒绝
    if (model.status == 0) {
        _agreeButton.hidden = NO;
        _refusedButton.hidden = NO;
        _statusTextLabel.hidden = YES;
        
    } else{
        _agreeButton.hidden = YES;
        _refusedButton.hidden = YES;
        _statusTextLabel.hidden = NO;
        
        if (model.status == 1) {
            _statusTextLabel.text = @"已同意";
        } else {
            _statusTextLabel.text = @"已拒绝";
        }
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
